package demo1;

/**
 * @Author liangzai
 * @Description:
 */
public class Test {
    //最小差值
    public int smallestRangeI(int[] nums, int k) {
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] >= max) {
                max = nums[i];
            }
            if (nums[i] <= min) {
                min = nums[i];
            }
        }
        return (max-min-2*k)<0?0:(max-min-2*k);
    }
}
